﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Entity;


namespace HdipCricketClub.Models
{
    public class ClubOtherFixtureDetailRepository
    {
        CricketClubEntities db = new CricketClubEntities();

        public ClubOtherFixtureDetail GetClubOtherFixtureDetails(int id)
        {
            return db.ClubOtherFixtureDetails.SingleOrDefault(cofd => cofd.fixture_id == id);
        }
        
        public double ClubTotalExtras(int id)
        {
            ClubOtherFixtureDetail clubOtherFixtureDetail = GetClubOtherFixtureDetails(id);

            double clubTotalExtras = 0;

            if (clubOtherFixtureDetail.byes != null)
            {
                clubTotalExtras += (double)clubOtherFixtureDetail.byes;
            }
            if (clubOtherFixtureDetail.leg_byes != null)
            {
                clubTotalExtras += (double)clubOtherFixtureDetail.leg_byes;
            }
            if (clubOtherFixtureDetail.wides != null)
            {
                clubTotalExtras += (double)clubOtherFixtureDetail.wides;
            }
            if (clubOtherFixtureDetail.no_balls != null)
            {
                clubTotalExtras += (double)clubOtherFixtureDetail.no_balls;
            }

            return clubTotalExtras;
        }



    }
}